//=========================================================================
//
//                  S Y N C M O S   T E C H N O L O G Y
//
//           COPYRIGHT (c)   2007 BY SyncMOS Technologies International,Inc.
//                     --  ALL RIGHTS RESERVED  --
//
// File Name : main.c    
// Created: 2007/10/11
// Author: Raleigh Chang
// Description:
//	This project is for SM59D04G2 EEPROM Demo
// Revision: 0.1
// History:
//=========================================================================
#include "main.h"
cByte TB[5],TC[10] ;
//code TB[5]={0x00,0x01,0x02,0x03,0x04};
extern void EEPROM_Byte_Program( Word eFlashAddr , Byte eFlashData );
extern void EEPROM_Page_Clean( Word eFlashAddr );
extern void EEPROM_Byte_change( Word eFlashAddrCustomer1,Word eFlashAddrBuffer1,Word eFlashAddr1 ,Byte eFlashData1, iWord Number1 );
extern void EEPROM_Byte_change_Eram( Word eFlashAddrCustomer,Word eFlashAddr ,Byte eFlashData, iWord Number );
//===============================
void main(void)
{		
//----------------Byte_Program---------------//
/*
		EEPROM_Page_Clean( 0x3000 );			//Page 0x3000 ~0x31FF clean before program
		EEPROM_Byte_Program( 0x3000 , 0x50);   	//Program 0x3000 to customer code 0x50
		EEPROM_Byte_Program( 0x3001 , 0x51);   	//Program 0x3001 to customer code 0x51   
		EEPROM_Byte_Program( 0x3002 , 0x52);   	//Program 0x3002 to customer code 0x52
		EEPROM_Byte_Program( 0x3003 , 0x53);   	//Program 0x3003 to customer code 0x53
		EEPROM_Byte_Program( 0x3100 , 0x60);   	//Program 0x3100 to customer code 0x60
		EEPROM_Byte_Program( 0x3101 , 0x61);   	//Program 0x3101 to customer code 0x61
		EEPROM_Byte_Program( 0x3102 , 0x62);   	//Program 0x3101 to customer code 0x61
		EEPROM_Byte_Program( 0x3103 , 0x63);   	//Program 0x3101 to customer code 0x61
*/
//----------------Byte Program_table---------------//		
		cByte TB[5]={0x20,0x21,0x22,0x23,0x24};
		cByte TC[10]={0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C};
		iWord	address;
		iByte	i;

		EEPROM_Page_Clean( 0x3000 );			//Page 0x3000 ~0x31FF clean before program

		address = 0X3000;						//Program TB table to 0x3000~0x3004
		for (i=0;i<5;i++)
		{
		EEPROM_Byte_Program( address , TB[i]); 
		address = address + 1;
		}

		address = 0x3100;						//Program TC table to 0x3100~0x3109				
		for (i=0;i<10;i++)
		{
		EEPROM_Byte_Program( address , TC[i]); 
		address = address + 1;
		}
//----------------byte_change_use Expand Ram to do buffer---------------//

		EEPROM_Byte_change_Eram( 0x3000,0x3001 ,0x55, 0x0200 );  //The customer code area from 0x3000 to 0x31FF;
															     //Change customer code at 0x3001 to 0x55, 
															     //Total use 512 Bytes (Max)
		EEPROM_Byte_change_Eram( 0x3000,0x3002 ,0xaa, 0x0200 );  //Change customer code at 0x3002 to 0xaa,
		EEPROM_Byte_change_Eram( 0x3000,0x3103 ,0x66, 0x0200 );  //Change customer code at 0x3103 to 0x66,
		EEPROM_Byte_change_Eram( 0x3000,0x3104 ,0x99, 0x0200 );  //Change customer code at 0x3104 to 0x99,

//----------------byte_change_use flash to do buffer---------------//
/*
		EEPROM_Byte_change( 0x3000,0x3C00,0x3005,0x66,0x0200 );	 //The customer code area from 0x3000 to 0x31FF;
																 //The Buffer code area from 0x3C00 to 0x3DFF;
																 //Change customer code at 0x3001 to 0xAA, 
																 //Total use 512 Bytes (Max)
		EEPROM_Byte_change( 0x3000,0x3C00,0x3006,0x99,0x0200 );	 //EEPROM_Byte_change(EEPROMstaradder,EEPROMchangeadder,EEPROMchangedata,Buffer size)
		EEPROM_Byte_change( 0x3000,0x3C00,0x3007,0x55,0x0200 );														 
		EEPROM_Byte_change( 0x3000,0x3C00,0x3008,0xaa,0x0200 );
*/

  
	while(1)
	{
	P2 = 0x55;
	}
}

